package com.example.simin_manage.admim.dto;

/**
 * @description:
 * @author: panpan
 * @time: 2025/9/14
 */


import lombok.Data;

@Data
public class Response<T> {
    private int code;     // 状态码
    private String msg;   // 提示信息
    private T data;       // 返回数据

    public Response() {}

    public Response(int code, String msg) {
        this(code, msg, null);
    }

    public Response(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    // 静态方法快速创建成功或失败响应
    public static <T> Response<T> ok(T data) {
        return new Response<>(200, "成功", data);
    }

    public static <T> Response<T> fail(String msg) {
        return new Response<>(400, msg, null);
    }
}
